package health.lm.com.shop.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.willy.ratingbar.ScaleRatingBar;

import java.util.List;

import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.component_base.widget.CircleImageView.CircleImageView;
import health.lm.com.shop.R;
import health.lm.com.shop.entity.EvaluationEntity;

/**
 * Created by Android Studio .
 * 作者：zhong
 * 日期：2018/11/22
 * 邮箱：15206394364@163.com
 * 介绍：
 * 修订：====================
 */
public class EvaluationAdapter extends BaseQuickAdapter<EvaluationEntity.EvaluationData, BaseViewHolder> {
    public EvaluationAdapter(@Nullable List<EvaluationEntity.EvaluationData> data) {
        super(R.layout.activity_mall_evaluation_all, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, EvaluationEntity.EvaluationData item) {
        CircleImageView circleImageView = helper.getView(R.id.civ_head);
        ImageLoaderHelper.getInstance().load(mContext, item.getEvaluation_head_img(), circleImageView);
        ScaleRatingBar ratingBar = helper.getView(R.id.rating_bar);
        //布局控制不起作用，必须代码控制
        ratingBar.setClickable(false);
        if (item.getEvaluation_rating() != null) {
            String rating = item.getEvaluation_rating().equals("") ? "0" : item.getEvaluation_rating();
            ratingBar.setRating(Float.parseFloat(rating));
        }
        helper.setText(R.id.tv_mobile, item.getEvaluation_mobile())
                .setText(R.id.tv_time, item.getEvaluation_time())
                .setText(R.id.tv_format, item.getEvaluation_format())
                .setText(R.id.tv_content, item.getEvaluation_content());
    }
}
